import { Injectable } from '@nestjs/common';
import { PrismaService } from '@/common/service/prisma/prisma.service';
import LoginFrontDto from '../Dto';
import { FrontAuthService } from '../service/front-auth.service';
@Injectable()
export class FrontService {
    constructor(private prisma: PrismaService,private auth:FrontAuthService) { } // 注入 PrismaServic

    async login(info: LoginFrontDto) {
        
        const result = await this.prisma.frontAccount.findMany({
            where: {
                userName: info.username,
                password: info.password
            }
        })
        if(result.length!=0){
            const token = this.auth.generateToken(info)
            return {
                token:token,
                message:'success',
                info:result
            }
        }else{
            return {
                message:'fail'
            }
        }
    }

}
